package com.twu.biblioteca.resources;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * User: arvind
 * Date: 22/9/13
 * Time: 11:15 AM
 * To change this template use File | Settings | File Templates.
 */
public class ReservationCatalog {

    private static ReservationCatalog catalogInstance=new ReservationCatalog();

    private static HashMap<String,String> reservationCatalog;

    private ReservationCatalog()
    {}

    public static ReservationCatalog getInstance()
    {
        return catalogInstance;
    }

    public void addEntry(String bookID,String memberID)
    {
        if(reservationCatalog==null)
            reservationCatalog=new HashMap<String, String>();
        reservationCatalog.put(bookID,memberID);

    }

    public boolean checkBookEntry(String bookID)
    {
        if(reservationCatalog==null)
            return false;
        else
            return reservationCatalog.containsKey(bookID);

    }

    public String reserveBook(String bookID) {

        if(!checkBookEntry(bookID))
        {
            addEntry(bookID,"dummyMemberID");
            return "Thank You! Enjoy the book.";
        }
        else
        {
            return "Sorry we don't have that book yet.";
        }

    }


}
